package com.factory;

import com.ktjy.dao.NewsDao;
import com.ktjy.dao.impl.NewsDaoImpl;

/**
 * 创建NewDao实例的工厂类
 */
public class SimpleDaoFactory {

    /**
     * 创建NewDao实例工厂方法
     */
//    public static NewsDao getInstance() {
//        //创建NewDao实例
//        return new NewsDaoImpl();
//    }

    public static NewsDao getInstance(String key) {
        switch (key) {
            case "mysql":
                return new NewsDaoImpl();
            case "oracle":
                return new NewsDaoImpl();
            case "redis":
                return new NewsDaoImpl();
            default:
                throw  new RuntimeException("无效的数据库类型"+key+",Dao获取失败");
        }
    }
}